package com.itheima.d2_buffered_stream;

import java.io.*;

/**
 * 目标：掌握字符缓冲输入流的用法。
 * 类型名：BufferedReader
 * 功能：基本的读取read方法使用和FileReader是一样的
 * 特殊功能：读行功能
 *      public String readLine()   一次读取一行数据并返回，若读取完毕，返回null
 */
public class Test2BufferedReader {
    public static void main(String[] args) throws FileNotFoundException {
        try(FileReader fr = new FileReader("day10io-app2/file/出师表.txt");
            BufferedReader br = new BufferedReader(fr)) {
            //读取一行
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());

            //public String readLine()   一次读取一行数据并返回，若读取完毕，返回null
            String line; //用来临时保存每次读取的行字符串
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
